package com.kgc.xs.pojo;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kgc.basic.annotation.DetailEntity;
import com.kgc.basic.annotation.PdfFieldMapping;
import com.kgc.basic.annotation.Validation;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public class SalesReturn implements Serializable {
    @ExcelIgnore
    private int id;

    @ExcelProperty("销售退货单据编号")
    private String docCode;

    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date docDate;
    @ExcelIgnore
    private int cid;

    @ExcelProperty("客户地址")
    private String customerAddress;

    @ExcelIgnore
    private int uid;

    @ExcelProperty("退货总金额")
    @Validation(required = true, message = "退货总金额不能为空")
    private BigDecimal totalReturnAmount;

    @ExcelProperty("已退总金额额")
    @Validation(required = true, message = "已退总金额不能为空")
    private BigDecimal actualReturnAmount;

    @ExcelProperty("欠款金额")
    private BigDecimal remainAccount;

    @ExcelIgnore
    private int status;

    @ExcelProperty("备注")
    private String notes;

    @ExcelProperty("创建人")
    private String createBy;

    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date createTime;

    @ExcelProperty("修改人")
    private String updateBy;

    @ExcelIgnore
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
    private Date updateTime;

    @ExcelIgnore
    private int isDelete;

    @ExcelProperty("源单")
    private String sourceSheet;

    @ExcelIgnore
    private int did;

    @ExcelIgnore
    private int typeId;

    @ExcelIgnore
    @DetailEntity(detailClass = SalesReturnDetail.class, relationField = "xsReturnCode")
    private List<SalesReturnDetail> details;


    //以下是自己计算的数据
    @ExcelProperty("欠款金额")
    private BigDecimal unActualReturnAmount;//未退金额

    @ExcelProperty("编码")
    private String code= "33613";


    //以下是连表查询的数据
    @ExcelProperty("业务员")
    private String  uidStr;
    @ExcelProperty("客户")
    private String  cidStr;
    @ExcelProperty("部门")
    private String didStr;




    public SalesReturn() {
    }

    public SalesReturn(int id, String docCode, Date docDate, int cid, String customerAddress, int uid, BigDecimal totalReturnAmount, BigDecimal actualReturnAmount, BigDecimal remainAccount, int status, String notes, String createBy, Date createTime, String updateBy, Date updateTime, int isDelete, String sourceSheet, int did, int typeId, List<SalesReturnDetail> details, BigDecimal unActualReturnAmount, String uidStr, String cidStr, String didStr) {
        this.id = id;
        this.docCode = docCode;
        this.docDate = docDate;
        this.cid = cid;
        this.customerAddress = customerAddress;
        this.uid = uid;
        this.totalReturnAmount = totalReturnAmount;
        this.actualReturnAmount = actualReturnAmount;
        this.remainAccount = remainAccount;
        this.status = status;
        this.notes = notes;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.updateTime = updateTime;
        this.isDelete = isDelete;
        this.sourceSheet = sourceSheet;
        this.did = did;
        this.typeId = typeId;
        this.details = details;
        this.unActualReturnAmount = unActualReturnAmount;
        this.uidStr = uidStr;
        this.cidStr = cidStr;
        this.didStr = didStr;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<SalesReturnDetail> getDetails() {
        return details;
    }

    public void setDetails(List<SalesReturnDetail> details) {
        this.details = details;
    }

    public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        this.typeId = typeId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getDocCode() {
        return docCode;
    }

    public void setDocCode(String docCode) {
        this.docCode = docCode;
    }

    public Date getDocDate() {
        return docDate;
    }

    public void setDocDate(Date docDate) {
        this.docDate = docDate;
    }

    public int getCid() {
        return cid;
    }

    public void setCid(int cid) {
        this.cid = cid;
    }

    public String getCustomerAddress() {
        return customerAddress;
    }

    public void setCustomerAddress(String customerAddress) {
        this.customerAddress = customerAddress;
    }

    public int getUid() {
        return uid;
    }

    public void setUid(int uid) {
        this.uid = uid;
    }

    public BigDecimal getTotalReturnAmount() {
        return totalReturnAmount;
    }

    public void setTotalReturnAmount(BigDecimal totalReturnAmount) {
        this.totalReturnAmount = totalReturnAmount;
    }

    public BigDecimal getActualReturnAmount() {
        return actualReturnAmount;
    }

    public void setActualReturnAmount(BigDecimal actualReturnAmount) {
        this.actualReturnAmount = actualReturnAmount;
    }

    public BigDecimal getRemainAccount() {
        return remainAccount;
    }

    public void setRemainAccount(BigDecimal remainAccount) {
        this.remainAccount = remainAccount;
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public int getIsDelete() {
        return isDelete;
    }

    public void setIsDelete(int isDelete) {
        this.isDelete = isDelete;
    }

    public String getSourceSheet() {
        return sourceSheet;
    }

    public void setSourceSheet(String sourceSheet) {
        this.sourceSheet = sourceSheet;
    }

    public int getDid() {
        return did;
    }

    public void setDid(int did) {
        this.did = did;
    }

    public String getUidStr() {
        return uidStr;
    }

    public void setUidStr(String uidStr) {
        this.uidStr = uidStr;
    }

    public String getCidStr() {
        return cidStr;
    }

    public void setCidStr(String cidStr) {
        this.cidStr = cidStr;
    }

    public String getDidStr() {
        return didStr;
    }

    public void setDidStr(String didStr) {
        this.didStr = didStr;
    }

    public BigDecimal getUnActualReturnAmount() {
        if (this.totalReturnAmount != null && this.actualReturnAmount != null) {
            return this.totalReturnAmount.subtract(this.actualReturnAmount);
        } else {
            return BigDecimal.ZERO; // 根据业务需求返回null或零
        }
    }

    public void setUnActualReturnAmount(BigDecimal unActualReturnAmount) {
        this.unActualReturnAmount = unActualReturnAmount;
    }

    @Override
    public String toString() {
        return "SalesReturn{" +
                "id=" + id +
                ", docCode='" + docCode + '\'' +
                ", docDate=" + docDate +
                ", cid=" + cid +
                ", customerAddress='" + customerAddress + '\'' +
                ", uid=" + uid +
                ", totalReturnAmount=" + totalReturnAmount +
                ", actualReturnAmount=" + actualReturnAmount +
                ", remainAccount=" + remainAccount +
                ", status='" + status + '\'' +
                ", notes='" + notes + '\'' +
                ", createBy='" + createBy + '\'' +
                ", createTime=" + createTime +
                ", updateBy='" + updateBy + '\'' +
                ", updateTime=" + updateTime +
                ", isDelete=" + isDelete +
                ", sourceSheet='" + sourceSheet + '\'' +
                ", did=" + did +
                '}';
    }
}

